package com.fc.test.api;

import com.fc.test.model.auto.TAbbScan;
import com.fc.test.service.TAbbScanService;
import com.fc.test.util.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "/apiScanController")
@Api(value = "浏览量")
public class ApiScanController {

    @Autowired
    private TAbbScanService scanService;

    @ResponseBody
    @PostMapping(value="getSacnNum",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "获得总浏览量")
    public String getSacnNum(){
        Map<String,Object> resultMap = new HashMap<>();
        TAbbScan scan = scanService.getSacnNum();
        if(null!=scan){
            resultMap.put("success",true);
            resultMap.put("totalNum",scan.getTotalnum());
            resultMap.put("msg","获取总浏览量成功");
        }else{
            resultMap.put("success",false);
            resultMap.put("msg","获取总浏览量失败");
        }
        return JsonUtil.jsonMapStr(resultMap);
    }

}
